<template>
	<view class="page">
		<view style="background-color: #fff; padding: 40rpx; margin: 20rpx;border-radius: 20rpx;">
			<u--form :borderBottom="true" :model="form" ref="uForm" labelPosition="top">
				<u-form-item :borderBottom="true" prop="mobile" label="手机号" labelWidth="200">
					<u-input border="none" v-model="form.mobile" placeholder="请输入手机号" />
				</u-form-item>
				<u-form-item :borderBottom="true" prop="verification_code" label="验证码" labelWidth="200">
					<u-input border="none" v-model="form.verification_code" placeholder="请输入验证码" />
					<text @tap="getCode" style="color: #962a22; font-size: 28rpx;" slot="right">{{codeTips}}</text>
				</u-form-item>
			</u--form>
			
			<view style="margin-top: 80rpx;">
				<u-button @click="submit" shape="circle" color="linear-gradient(to left, #e44e15, #f4aa56)">确认绑定</u-button>
			</view>
		</view>
		<!-- <u-loading mode="flower" size="100" :show="loadShow" style="display: flex;justify-content: center;align-items: center;"></u-loading> -->
	</view>
</template>

<script>
	import {sendSms, bindMobile} from '../../common/http.api.js'
	export default {
		data() {
			return {
				codeTips: '获取验证码',
				form: {
					name: '',
					mobile: '',
					verification_code: '',
					code: ''
				},
				leftIconStyle: {
					color: '#999'
				},
				seconds: 60,
				loadShow: true
			}
		},
		onLoad({name, mobileText}) {
			this.form.mobile = mobileText
			this.form.name = name
<<<<<<< HEAD
		},
		methods: {
			codeChange(text) {
				this.codeTips = text;
			},
			getCode() {
				uni.showLoading({
					title: '正在获取验证码'
				})
				let __this = this;
				this.$u.api.sendSms({
=======
		},
		methods: {
			codeChange(text) {
				this.codeTips = text;
			},
			getCode() {
				uni.showLoading({
					title: '正在获取验证码'
				})
				let __this = this;
				sendSms({
>>>>>>> pingtuan
					mobile: this.form.mobile,

					type: 'bind'
				}).then(res => {
					uni.hideLoading()
					__this.$u.toast('验证码已发送');
				})
			},

			submit() {
				uni.showLoading({
					title: '正在绑定用户信息'
				})
				let __this = this;
				bindMobile({
					...this.form
				}).then(res => {
					uni.hideLoading()
					__this.$u.toast('绑定成功');
					uni.$emit('updateUserInfo',{msg:'刷新用户信息'})
					__this.$u.route({
						type: 'navigateBack',
						// delta: uni.getStorageSync('pageNum') + 1
					})

				})
			}
		}
	}
</script>


<style lang="scss">
	@import "../../static/iconfont.css";

	.page {
		background-color: #fff;
		min-height: 100Vh;
		width: 100vw;
	}

	.footer {
		margin-top: 32upx;
		font-size: 24upx;
		color: #666666;
		text-align: center;
		display: flex;
		justify-content: center;
	}

	// .leftIconStyle {
	// 	width: 30rpx;
	// 	height: 30rpx;
	// 	align-items: center;
	// }
</style>
